# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=tar
pkgver=1.28
pkgrel=3
pkgdesc="Utility used to store, backup, and transport files"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/tar/tar.html"
license=('GPL3')
groups=('compression')
depends=('msys2-runtime' 'libiconv' 'libintl' 'sh')
makedepends=('libiconv-devel' 'gettext-devel')
options=('!emptydirs')
install=tar.install
source=(ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz{,.sig}
        1.25-mode-binary.patch
        tar-1.27-msys2.patch)
md5sums=('49b6306167724fe48f419a33a5beb857'
         'SKIP'
         '9b8737e4be2e3d788815fc8770b158c9'
         '6d22773bcbe16a24ca3daaa10944b099')

prepare() {
  cd ${srcdir}/$pkgname-$pkgver

  patch -p2 -i ${srcdir}/1.25-mode-binary.patch
  patch -p1 -i ${srcdir}/tar-1.27-msys2.patch

  autoreconf -fi
}

build() {
  cd ${srcdir}/$pkgname-$pkgver
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/tar \
    --enable-backup-scripts
  make
}

check() {
  cd ${srcdir}/$pkgname-$pkgver
  make check
}

package() {
  cd ${srcdir}/$pkgname-$pkgver
  make DESTDIR=${pkgdir} install
}
